<%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2023/12/25
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <style>
        .footer {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        input {
            width: 50%;
        }
    </style>
</head>
<body>
<div class="skin-default" id="wrapper">
    <%@include file="/static/pages/head/header.jsp" %>
    <div class="page-wrapper">
        <div class="page-header">
            <h1 class="title">
                处理工厂
                <small>查看自行处理记录</small>
            </h1>
        </div>
        <section class="page-body">
            <div class="row widget">
                <section class="col-md-12">
                    <div class="box table">
                        <div class="box-body">
                            <form method="post" action="${pageContext.request.contextPath}/discretion/list" title="form">
                                <input type="hidden" name="pageNo" value="1">
                                <div class="form-group" style="width: 400px;float: left">
                                    <label>操作人:</label>
                                    <select class="form-control" style="width: 200px" name="userId">
                                        <option value="-1">请选择</option>
                                        <c:forEach items="${users}" var="user">
                                            <option value="${user.userId}" ${user.userId==param.userId?"selected='selected'":""}>${user.infoRealname}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                                <div class="form-group" style="width: 400px;float: left;margin-left: -180px">
                                    <label>日期选择:</label>
                                    <select class="form-control" style="width: 200px" name="time">
                                        <option value="-1">请选择</option>
                                        <c:forEach items="${timeList}" var="t">
                                            <option value="${t.time}" ${t.time==param.time?"selected='selected'":""}>${t.name}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                                <button type="submit" class="btn btn-default"
                                        style="margin-top: 25px;margin-left: -180px">查询
                                </button>
                                <button type="button" title="excel" class="btn btn-primary"
                                        style="margin-left: 600px;margin-top: 5px">导出excel
                                </button>
                            </form>
                        </div>
                        <div class="box-body">
                            <table class="table table-striped">
                                <tr>
                                    <td>序号</td>
                                    <td>自行处理编码</td>
                                    <td>自行处理时间</td>
                                    <td>自行处理量</td>
                                    <td>自行处理单位</td>
                                    <td>自行处理类型</td>
                                    <td>废物来源</td>
                                    <td>废物编码</td>
                                    <td>操作人</td>
                                </tr>
                                <c:forEach items="${pageInfo.list}" var="discretion">
                                    <tr>
                                        <td>${discretion.discretionId}</td>
                                        <td>${discretion.discretionCode}</td>
                                        <td><fmt:formatDate value="${discretion.discretionTime}" pattern="yyyy-MM-dd"/></td>
                                        <td>${discretion.discretionNum}</td>
                                        <td>${discretion.discretionUnit}</td>
                                        <td>${discretion.discretionType}</td>
                                        <td>${discretion.wasteSource}</td>
                                        <td>${discretion.wasteCode}</td>
                                        <td>${discretion.userName}</td>
                                    </tr>
                                </c:forEach>
                            </table>
                        </div>
                        <div style="margin-left: 20px">
                            共${pageInfo.total}条数据,当前第${pageInfo.pageNum}页,共${pageInfo.pages}页
                        </div>
                        <div class="footer">
                            <nav aria-label="Page navigation">
                                <ul class="pagination">
                                    <li>
                                        <a href="javascript:void(0);" aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                    <c:forEach items="${pageInfo.navigatepageNums}" var="num">
                                        <li><a href="javascript:void(0);">${num}</a></li>
                                    </c:forEach>
                                    <li>
                                        <a href="javascript:void(0);" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </section>
            </div>
        </section>
    </div>
</body>
</html>
<script>
    $(function () {
        $("ul.pagination li:first").click(function () {
            var num = ${pageInfo.pageNum};
            if (num == 1) {
                goPage(1);
            } else {
                goPage(num - 1);
            }
        })
        $("ul.pagination li").not(":first").not(":last").click(function () {
            var num = $(this).text();
            goPage(num);
        })
        $("ul.pagination li:last").click(function () {
            var num = ${pageInfo.pageNum};
            if (num ==${pageInfo.pages}) {
                goPage(${pageInfo.pages});
            } else {
                goPage(num + 1);
            }
        })


    })

    function goPage(pageNo) {
        $("[name='pageNo']").val(pageNo);
        $("[title='form']").submit();
    }

    $("[title='excel']").click(function () {
        var pageNo = $("[name='pageNo']").val();
        var url = "${pageContext.request.contextPath}/discretion/excel";
        $("[title='form']").attr('action',url);
        $("[title='form']").attr('method','post');
        goPage(pageNo)
    })
    $("[type='submit']").click(function (){
        var url = "${pageContext.request.contextPath}/discretion/list";
        $("[title='form']").attr('action',url);
    })


</script>

